package com.study.service.impl;

import com.study.dao.OrdersDao;
import com.study.pojo.Orders;
import com.study.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;


/**
 * @Author Miss kun
 * @Date 2020/10/8 20:20
 * @Version 1.0
 */
@Service
public class OrdersServiceImpl implements OrdersService {

    @Autowired
    private OrdersDao OrdersDao;

    @Override
    public int insertOrders(Orders orders) {
        Date date = new Date();
        orders.setDate(new Date(date.getTime()));
        return OrdersDao.insertOrders(orders);
    }

    @Override
    public boolean findOrdersByUserIdAndBookId(Integer userId, Integer bookId) {
        return OrdersDao.findOrdersByUserIdAndBookId(userId,bookId) != null ? true :false;
    }

    @Override
    public Orders findOrdersByUserIdAndBook(Integer userId, Integer bookId) {
        return OrdersDao.findOrdersByUserIdAndBookId(userId,bookId);
    }

    @Override
    public int updateStatus(Integer userId, Integer bookId, Integer statue) {
        return OrdersDao.updateStatus(userId,bookId,statue);
    }

    @Override
    public List<Orders> getMyOrdersBook(Integer id, Integer status) {
        return OrdersDao.getMyOrdersBook(id,status);
    }

    @Override
    public int updateChapterInfo(String title, Integer chapterId, Integer userId, Integer bookId) {
        Date date = new Date();
        return OrdersDao.updateChapterInfo(title,chapterId,userId,bookId,new Date(date.getTime()));
    }

    @Override
    public int updateBookStatus(Integer id,Integer status) {
        return OrdersDao.updateBookStatus(id,status);
    }
}
